<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
	</head>
	<body>
	<script>
		function delElement(arr,index)
		{
			for(var i=index;i<arr.length-1;i++)
			{
				arr[i]=arr[i+1];
			}
			//arr.length=arr.length-1;
			arr.length--;
		}
		/*
		function getIndex(arr,index){
			length = arr.length;
			while(true)
				if (index>0 && index<length){
				return index;
				}
			prompt("请输入1至"+length+"范围内的数。")
			return false
		}*/
		arr = [23,54,657,6,34,7654,5];
		index = parseInt(prompt("请输入要删除元素的下标："));
		length = arr.length;
		while(true)
		{
			if (index>=0 && index<length)
			{
				delElement(arr,index);
				break;
			}
			else
			{
				index = prompt("请输入0至"+length - 1+"范围内的数。");
			}
		}
			
		//打印整个数组
		for(var j=0;j<arr.length;j++)
		{
			document.write(arr[j]+',');
		}
	</script>	
	</body>
</html>